package com.marvels.dubbo.coreservice.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.dragon.loan.entity.AcUserBank;
import com.dragon.loan.entity.McamAcLoanApplyBdInfo;
import com.dragon.loan.entity.McamAcLoanApplyImageInfo;
import com.dragon.loan.entity.McamLoanApplyInfo;
import com.marvels.common.utils.MarvelsLogUtil;
import com.marvels.dubbo.coreservice.dto.LoanExtInfoDTO;
import com.marvels.dubbo.coreservice.service.ILoanApplyInfoService;

@RestController
@RequestMapping("dubbo/loan_apply_info/api")
public class LoanApplyInfoController {
	@Autowired
	private ILoanApplyInfoService loanApplyInfoService;
	@RequestMapping("querySysRoles")
	public McamLoanApplyInfo queryLoanBasicInfo(@RequestParam(value="loanId") String loanId){ 
		try {
			McamLoanApplyInfo info = loanApplyInfoService.findLoanApplyInfo(loanId);
			return info;
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(loanId+"##############",e);
			return null;
		}
	}
	
	@RequestMapping("queryApplyInfo")
	public List<McamAcLoanApplyBdInfo> queryApplyInfo(@RequestParam(value="loanId") String loanId){ 
		try {
			List<McamAcLoanApplyBdInfo> info = loanApplyInfoService.findLoanApplyBdInfo(loanId);
			return info;
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(loanId+"##############",e);
			return null;
		}
	}
	
	@RequestMapping("queryImageInfo")
	public List<McamAcLoanApplyImageInfo> queryImageInfo(@RequestParam(value="loanId") String loanId){ 
		try {
			List<McamAcLoanApplyImageInfo> info = loanApplyInfoService.findLoanApplyImageInfo(loanId);
			return info;
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(loanId+"##############",e);
			return null;
		}
	}
	
	@RequestMapping("queryLinkmanList")
	public List<LoanApplyContactInfoDTO> queryLinkmanList(@RequestParam(value="loanId") String loanId){
		try {
			List<LoanApplyContactInfoDTO> info= loanApplyInfoService.queryLinkmanList(loanId);
			return info;
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(loanId+"##############",e);
		}
		return null;
	}
	@RequestMapping("queryLoanInfoByCondition")
	public Map<String,Object> queryLoanInfoByCondition(@RequestBody Map<String,Object> map){
		try {
			Map<String, Object> info= loanApplyInfoService.queryLoanInfoByCondition(map);
			return info;
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(map+"##############",e);
		}
		return null;
	}
	
	@RequestMapping("selectUserBankInfo")
	public List<AcUserBank> selectUserBankInfo(@RequestBody Map<String,Object> paramMap){
		try {
			List<AcUserBank> info= loanApplyInfoService.selectUserBankInfo(paramMap);
			return info;
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(paramMap+"##############",e);
		}
		return null;
	}
	
	@RequestMapping("queryExtInfo")
	public LoanExtInfoDTO queryExtInfo(@RequestParam(value="loanId") String loanId){
		MarvelsLogUtil.getInstance().info("loan:" + loanId + "，开始获取进件扩展信息");
		return loanApplyInfoService.queryExtInfoByLoanId(loanId);
	}
	
	@RequestMapping("updateLoanMoneyAct")
	public void updateLoanMoneyAct(@RequestParam(value="loanId") String loanId, @RequestParam(value="loanMoneyAct") String loanMoneyAct){
		MarvelsLogUtil.getInstance().info("loan:" + loanId + "，开始修改审核金额");
		loanApplyInfoService.updateLoanMoneyAct(loanId, loanMoneyAct);
		MarvelsLogUtil.getInstance().info("loan:" + loanId + "，修改审核金额完成");
	}
	
	/**
	 * 进件节点流转
	 * @param loanId
	 * @param result  yes通过，no拒绝
	 */
	@RequestMapping("loanNodeFlow")
	public void loanNodeFlow(@RequestParam(value="loanId") String loanId, @RequestParam(value="result") String result){
		MarvelsLogUtil.getInstance().info("loan:" + loanId + "，开始流转节点，result:" + result);
		loanApplyInfoService.loanNodeFlow(loanId, result);
		MarvelsLogUtil.getInstance().info("loan:" + loanId + "，流转节点");
	}
	
}
